﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 账号管理
{
    public partial class FormPwd : Form
    {
        public FormPwd()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            IDatabase db = DatabaseFactory.CreateDatabase("sqlite");
            if (Function.CacheUser.UserPass == txtOldPwd.Text)
            {
                int count = db.ExecuteNonQuery("update 用户 set 密码=@pwd where 用户=@user", new { pwd = txtPwd.Text, user = Function.CacheUser.UserName });
                if (count > 0)
                {
                    MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("请输入正确的旧密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
